package com.zcloud.eventstudydemo.dto;

import lombok.Data;

@Data
public class RestWebResponse<T> {

	private String code;

	private String msg;

	private T data;

	public RestWebResponse(String code, String msg, T data) {
		this.code = code;
		this.msg = msg;
		this.data = data;
	}

	public static <T> RestWebResponse<T> success(T data) {
		return new RestWebResponse<>("200", "success", data);
	}

	public static RestWebResponse<Void> success() {
		return new RestWebResponse<>("200", "success", null);
	}

	public static RestWebResponse<Void> error(BaseException cause) {
		return new RestWebResponse<>(cause.getCode(), cause.getMessage(), null);
	}

}